package com.kintreda.ieco_server.bean.account;

import com.kintreda.ieco_server.bean.system.BaseVo;
import com.kintreda.ieco_server.util.StringUtil;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

/**
 * 用户信息表
 * @author HuangZhongYao
 *
 */
@Entity
@Table(name = "common_user")
public class User extends BaseVo {

	private static final long serialVersionUID = -926874738132420619L;
	//status:0表示禁用、1表示正常、
	private String userCode="";// 用户帐号
	private String name; //用户姓名
	private String mobile;// 手机号
	private String idcard; //身份证号
	private String gender; //性别  0-女,1-男
	private String password;// 密码
	private String trueName;//真实姓名
	private String salt = StringUtil.getRandom(4);// 密码盐
	private String lastLoginTime;// 最后一次登录时间
	private String address; //
	private String avatar;//微信头像url
	private String pid;//上级部门
	private String orgId="";//所属机构
	private String type;// 1 admin 2用户 , 3机构管理员 4机构用户 5系统运营
	private String openId;//openid
	private Integer isBindingMobile = 0;//是否绑定手机 0 否 1 是

	@ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.EAGER)
	@JoinTable(name = "common_user_role", joinColumns = { @JoinColumn(name = "userId", referencedColumnName = "id") }, inverseJoinColumns = { @JoinColumn(name = "roleId", referencedColumnName = "id") })
	private Set<Role> roles = new HashSet<Role>();  //用户角色

	//------------临时变量-----------------------
	@Transient
	private Role role;
	@Transient
	private String depName;

	public static long getSerialVersionUID() {
		return serialVersionUID;
	}

	public String getPid() {
		return pid;
	}

	public void setPid(String pid) {
		this.pid = pid;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getUserCode() {
		return userCode;
	}

	public void setUserCode(String userCode) {
		this.userCode = userCode;
	}
	public String getIdcard() {
		return idcard;
	}

	public void setIdcard(String idcard) {
		this.idcard = idcard;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getPassword() {
		return password;
	}

	public String getGender() {
		return gender;
	}

	public void setGender(String gender) {
		this.gender = gender;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getSalt() {
		return salt;
	}

	public void setSalt(String salt) {
		this.salt = salt;
	}

	public String getLastLoginTime() {
		return lastLoginTime;
	}

	public void setLastLoginTime(String lastLoginTime) {
		this.lastLoginTime = lastLoginTime;
	}


	public Set<Role> getRoles() {
		return roles;
	}

	public void setRoles(Set<Role> roles) {
		this.roles = roles;
	}

	public Role getRole() {
		return role;
	}

	public void setRole(Role role) {
		this.role = role;
	}


	public String getTrueName() {
		return trueName;
	}

	public void setTrueName(String trueName) {
		this.trueName = trueName;
	}

	public String getOrgId() {
		return orgId;
	}

	public void setOrgId(String orgId) {
		this.orgId = orgId;
	}

	public String getOpenId() {
		return openId;
	}

	public void setOpenId(String openId) {
		this.openId = openId;
	}

	public String getAvatar() {
		return avatar;
	}

	public void setAvatar(String avatar) {
		this.avatar = avatar;
	}

	public Integer getIsBindingMobile() {
		return isBindingMobile;
	}

	public void setIsBindingMobile(Integer isBindingMobile) {
		this.isBindingMobile = isBindingMobile;
	}

	public String getDepName() {
		return depName;
	}

	public void setDepName(String depName) {
		this.depName = depName;
	}
}